package cn.ekgc.bmdsad.day13;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

public class C {
    static Scanner input = new Scanner ( System.in );

    public static void main(String[] args) {
        try (Socket c = new Socket ( "192.168.110.150", 8080 )) {
            System.out.println ( "ok...." );
            new Thread ( () -> {
                try {
                    BufferedReader in = new BufferedReader ( new InputStreamReader ( c.getInputStream () ) );
                    while (true) {
                        System.out.println ( in.readLine () );
                    }
                } catch (IOException e) {
                    e.printStackTrace ();
                }
            } ).start ();


            PrintWriter out = new PrintWriter ( c.getOutputStream () );
            while (true) {
                String msg = input.nextLine ();
                out.println ( msg );
                out.flush ();
            }
        } catch (IOException e) {
            e.printStackTrace ();
        }
    }
}
